package yuan.algorithm.searching;

public class SequentialSearch {
	
	public static int search(int[] inputs, int key){
		
		for (int i=1;i<inputs.length;i++){
			if (inputs[i] == key)
				return i;
		}
		
		return 0;
	}
	
	public static int search2(int[] inputs, int key){
		inputs[0] = key;
		int i= inputs.length-1;
		while(inputs[i]!=key)
			i--;
		
		return i;
	}
	
	public static void main(String[] args){
		int[] inputs = new int[90000001];
		
		long begin = System.currentTimeMillis();
		search(inputs, 1);
		System.out.println(System.currentTimeMillis()-begin);
		
		begin = System.currentTimeMillis();
		search2(inputs, 1);
		System.out.println(System.currentTimeMillis()-begin);
	}
}
